// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import axios from '@/utils/axiosconfig.js'

// 导入babel-polyfill
import 'babel-polyfill'

Vue.use(ElementUI);
Vue.prototype.$http = axios;
Vue.config.productionTip = false;


//路由全局守卫
router.beforeEach(function(to, from, next) {
    if (to.meta.isLogin) {
        if (localStorage.getItem('token')) {
            window.document.title = to.meta.title
            next()
        } else {
            window.document.title = to.meta.title
            next({ path: '/login' })
        }
    } else {
        window.document.title = to.meta.title
        next()
    }
})

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
})
